<template>
  <div class="productItemHor" @click="$router.push('/detail/' + item.id)">
    <div class="img">
      <van-image lazy-load fit="cover" :src="item.image" />
    </div>
    <div class="info">
      <div class="name">
        {{ item.store_name }}
      </div>
      <div class="detail">
        <div class="price">￥{{ item.price }}</div>
        <div class="bottom">
          <div class="vip_price">￥{{ item.vip_price }}</div>
          <div class="sales">已售{{ item.sales | formatNum }}件</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: ["item"],
  filters: {
    formatNum(value) {
      return value > 10000
        ? (value / 10000).toFixed(1).replace(/\.0$/, "") + "w"
        : value > 1000
        ? (value / 1000).toFixed(1).replace(/\.0$/, "") + "k"
        : value;
    },
  },
};
</script>

<style lang="less" scoped>
.productItemHor {
  overflow: hidden;
  display: flex;

  .img {
    flex-shrink: 0;
    width: 90px;
    height: 90px;
    border-radius: 5px;
    overflow: hidden;
    .van-image {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }
  &:not(:last-of-type) {
    margin-top: 15px;
    .info {
      border-bottom: 1px solid #f5f5f5;
    }
  }
  .info {
    flex: 1;
    width: 0;
    box-sizing: border-box;
    padding: 5px 0;
    padding-left: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .name {
      font-size: 15px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .detail {
      .price {
        font-weight: bold;
        font-size: 16px;
        color: #24c1bb;
      }
      .bottom {
        display: flex;
        justify-content: space-between;
        font-size: 12px;
        .vip_price {
          font-weight: bold;
          color: #282828;
          &::after {
            content: "VIP";
            line-height: 12px;
            padding: 2px 6px;
            transform: scale(0.65);
            display: inline-block;
            color: rgb(248, 226, 125);
            background-color: #282828;
            border-radius: 5px;
          }
        }
        .sales {
          color: #ccc;
        }
      }
    }
  }
}
</style>